<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>后台首页</title>
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap.min.css" />
    <link rel="stylesheet" href="/php/tpblog/public/BootStrap/css/bootstrap-rtl.css" />
    <script type="text/javascript" src="/php/tpblog/public/js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/BootStrap/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="/php/tpblog/public/js/layer.js"></script>
</head>
<body>
<nav class="navbar navbar-inverse">
    <div class="container">
        <!-- Brand and toggle get grouped for better mobile display -->
        <div class="navbar-header">
            <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
                <span class="icon-bar"></span>
            </button>
            <a class="navbar-brand" href="#">بىلوگ سېستىىسى </a>
        </div>

        <!-- Collect the nav links, forms, and other content for toggling -->
        <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
            <ul class="nav navbar-nav">
                <li <?php if(CONTROLLER_NAME == 'Index'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Index/index');?>">باشبەت <span class="sr-only">(current)</span></a></li>
                <li <?php if(CONTROLLER_NAME == 'Category'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Category/index');?>">مەزمۇن</a></li>
                <li <?php if(CONTROLLER_NAME == 'User'): ?>class="active"<?php endif; ?>><a href="<?php echo U('User/index');?>">باشقۇرغۇچىلار</a></li>
                <li <?php if(CONTROLLER_NAME == 'Navs'): ?>class="active"<?php endif; ?>><a href="<?php echo U('Navs/index');?>">ئىقتىدار</a></li>
            </ul>
            <ul class="nav navbar-nav navbar-right">
                <li><a href="/php/tpblog/index.php" target="_blank">ئالدى بەت</a></li>
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">ياخشىمۇسىز <?php echo ($sessions['auser']); ?><span class="caret"></span></a>
                    <ul class="dropdown-menu">
                        <?php $a_aid=$sessions['aid'] ?>
                         <li><a href="<?php echo U('User/edit',array('aid'=>$a_aid));?>">ئارخىب تەھرىرلەش</a></li>
                        <li><a href="<?php echo U('Index/logout');?>">بىخەتەر چېكىنىش </a></li>
                    </ul>
                </li>
            </ul>
        </div><!-- /.navbar-collapse -->
    </div><!-- /.container-fluid -->
</nav>
<div class="container">
    <div class="row">
        <div style="height: 30px"></div>
        <div class="col-md-2">
            <ul class="list-group">
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Navs'): ?>active<?php endif; ?>"><a href="<?php echo U('Navs/index');?>">تىزىملىك باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Sliders'): ?>active<?php endif; ?>"><a href="<?php echo U('Sliders/index');?>">چوڭ ئايلانما ئېلان باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Links'): ?>active<?php endif; ?>"><a href="<?php echo U('Links/index');?>">دوستانە ئۇلىنىش باشقۇرۇش</a></li>
    <li class="list-group-item <?php if(CONTROLLER_NAME == 'Configs'): ?>active<?php endif; ?>"><a href="<?php echo U('Configs/index');?>">تەڭشەك باشقۇرۇش</a></li>
</ul>
<style>
    .list-group .active a{
        color: #fff;
    }
</style>

        </div>
        <div class="col-md-10">
            <div class="page-header">
                <h4><?php echo ($page_title); ?></h4>
            </div>
            <div class="btn-group" role="group" aria-label="...">
                <a  href="<?php echo U('Configs/index');?>" type="button" class="btn btn-default">بارلىق تەڭشەكلەر</a>
                <a href="<?php echo U('Configs/add');?>" type="button" class="btn btn-default">يېڭىدىن قوشۇش</a>
            </div>
            <br><br>
            <form action="<?php echo U('Configs/saveadd');?>" method="post">
                <table class="table table-bordered">
                    <thead>
                    <tr class="active">
                        <td width="30">ID</td>
                        <td> ئىشلىتىلىش چۈشەندۈرۈلىشى </td>
                        <td> تەڭشەك نامى</td>
                        <td>ھەرقايسى بەتلەدە كۆرۈنىدىغان قىممىتى</td>
                        <td>مەشغۇلات</td>
                    </tr>
                    </thead>
                    <tbody>
                    <?php if(is_array($configs)): foreach($configs as $key=>$c): ?><input type="hidden" name="id[]" value="<?php echo ($c['id']); ?>" />
                        <tr>
                            <td><?php echo ($c['id']); ?></td>
                            <td><?php echo ($c['title']); ?></td>
                            <td style="direction: ltr;font-size: 15px" class="text-center"><?php echo ($c['name']); ?></td>
                            <td><input onchange="bianji(this,<?php echo ($c['id']); ?>)" type="text" class="form-control" value="<?php echo ($c['value']); ?>" name="value[]"></td>
                            <td>
                                <a  href="<?php echo U('Configs/edit',array('id'=>$c['id']));?>" class="btn btn-success btn-sm">چوڭ تەھرىرلەش</a>
                                <a  href="javascript:deleteConfig(<?php echo ($c['id']); ?>)" class="btn btn-danger btn-sm">ئۆچۈرۈش</a>
                            </td>
                        </tr><?php endforeach; endif; ?>
                    </tbody>
                </table>
                <!--<input type="submit" class="btn btn-primary" value="يېڭىلاش">-->
            </form>
        </div>
        <script type="text/javascript">
            //编辑
            function bianji(obj,id) {
                var value=$(obj).val();
                $.ajax({
                    'url':'<?php echo U("Configs/bianji");?>',
                    'type':'POST',
                    'dataType':'json',
                    'data':{'value':value,'id':id},
                    success:function (phpRetrnData) {
                        if(phpRetrnData.status){
                            layer.msg(phpRetrnData.message,{'icon':6},function () {
                                window.location=location;
                            })
                        }else {
                            layer.msg(phpRetrnData.message,{'icon':5});
                        }
                    }
                })
            }

            function deleteConfig(id) {
                //询问框
                layer.confirm('راستىنلا ئۆچۈرەمسىز？', {
                    btn: ['ھەئە','ياق'] //按钮
                }, function(){
                    $.ajax({
                        'url':"<?php echo U('Configs/deleteConfig');?>",
                        'type':'POST',
                        'dataType':'json',
                        'data':{'id':id},
                        success:function (phpRetrnData) {
                            if(phpRetrnData.status){
                                layer.msg(phpRetrnData.message,{'icon':6},function () {
                                    window.location=location;
                                })
                            }else {
                                layer.msg(phpRetrnData.message,{'icon':5});
                            }
                        }
                    });
                })
            }
        </script>
</body>
</html>